<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 直接通过原型链继承会导致子类更改父类后，其他继承这个父类的子类的原型被更改
      function Parent(type) {
        this.pType = type;
      }
      function Children1(type) {
        this.cType1 = type;
      }


      // 继承的关键步骤
      Children1.prototype = new Parent("p1");


      let c2 = new Children1(2);
      
      // 这个步骤会导致c2的原型也被修改
      Children1.prototype.test = 1;
      let c1 = new Children1(1);

      console.log(c1, c2);
    </script>
  </body>
</html>
